import { defineStore } from 'pinia'
import type { Brand } from "../model/brand.ts"
import axios from "../utils/request.ts"

export const useBrandsStore = defineStore('brands', {
    state: (): { brands: Brand[] } => ({
        brands: []
    }),
    persist: true,
    actions: {
        async fetchBrands() {
            const response = await axios.get<Brand[]>('/brands/list')
            this.brands = response.data  // ✅ 直接赋值整个数组
        },
    }
})